package com.countryfinancial.android;

import android.os.Bundle;
import android.app.Activity;
import android.app.ProgressDialog;
import android.view.Menu;
import android.view.MotionEvent;
import android.view.View;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;

public class HelpActivity extends Activity {

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_help);
        // Setting up the webview
        WebView myWebView = (WebView) findViewById(R.id.help);
        WebSettings webSettings = myWebView.getSettings();
        webSettings.setJavaScriptEnabled(true);
        //myWebView.addJavascriptInterface(new JavscriptInterface(this), "Android");

        myWebView.setWebViewClient(new WebViewClient() {
          //Progress at the center of the screen
          ProgressDialog  dialog = ProgressDialog.show(HelpActivity.this, "","Please wait loading...");
          
          @Override
          public void onReceivedError(WebView view, int errorCode,
              String description, String failingUrl) {
            // Handle the error
          }

          @Override
          public boolean shouldOverrideUrlLoading(WebView view, String url) {
            view.loadUrl(url);          
            return true;
          }
          
          @Override
          public void onPageFinished(WebView view, String url)  {
            dialog.dismiss();
          }
                
        });

        myWebView.loadUrl(getResources().getString(R.string.help_url));           
        
        myWebView.setOnTouchListener(new View.OnTouchListener() {

            public boolean onTouch(View v, MotionEvent event) {
              return (event.getAction() == MotionEvent.ACTION_MOVE);
            }
        });         
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        getMenuInflater().inflate(R.menu.activity_help, menu);
        return true;
    }
}
